home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-09-18 | 5.5 KB | 256 lines | [TEXT/PJMM] |
- unit QLowLevel;
- (*}
- {# Copyright Department of Computer Science}
- {# University of Western Australia}
- {# Modified : Quinn}
- {# Station : Eriodon}
- {# Date : Monday, 4 November 1991}
- {}
- {Really sleasy stuff that it not for the faint of heart.}
- {}
- {*)
- interface
-
- {$IFC undefined THINK_Pascal}
- uses
- Types;
- {$ENDC}
-
- (* Global Bashing - Get constants from SysEqu.p *)
- function GetGlobalB (ad: univ longint): SignedByte;
- procedure SetGlobalB (ad: univ longint; b: SignedByte); (* not univ cause}
- {I dont trust Pascal *)
-
- function GetGlobalW (ad: univ longint): integer;
- procedure SetGlobalW (ad: univ longint; w: univ integer);
-
- function GetGlobalL (ad: univ longint): longint;
- procedure SetGlobalL (ad: univ longint; l: univ longint);
-
- function GetGlobalS (ad: univ longint): Str255;
- procedure SetGlobalS (ad: univ longint; s: Str255); (* only bashes len+1 chars *)
-
- (* Calling *)
- procedure CallProcPtr (ad: univ ProcPtr);
- inline
- $205F, (* move.l (a7)+,a0 ; pop proc address *)
- $4E90; (* jsr (a0) ; call proc *)
-
- (* Pointer Arithmetic *)
- function AddPtrLong (p: univ Ptr; offset: longint): Ptr;
- inline
- $201F, (* move.l (sp)+,d0 ; pop offset *)
- $D09F, (* add.l (sp)+,d0 ; add ptr to offset (and pop p) *)
- $2E80; (* move.l d0,(sp) ; place in result *)
-
- procedure OffsetPtr (var p: univ Ptr; offset: longint);
- inline
- $201F, (* move.l (sp)+,d0 ; pop offset *)
- $205F, (* move.l (sp)+,a0 ; pop address of p *)
- $D190; (* add.l d0,(a0) ; add offset to p *)
-
- function SubPtrPtr (leftp, rightp: univ Ptr): longint;
- inline
- $201F, (* move.l (sp)+,d0 ; pop rightp *)
- $A055, (* _StripAddress ; strip if needed *)
- $2200, (* move.l d0,d1 ; store in d1 *)
- $201F, (* move.l (sp)+,d0 ; pop leftp *)
- $A055, (* _StripAddress ; strip if needed (reg traps preserve d1) *)
- $9081, (* sub.l d1,d0 ; d0 := leftp - rightp *)
- $2E80; (* move.l d0,(sp) ; place result *)
-
- (* unsigned comparisons *)
-
- function CompLS (a1, a2: univ longInt): boolean;
- inline
- $BF8F, $53C0, $4257, $4400, $1E80;
-
- function CompLO (a1, a2: univ longInt): boolean;
- inline
- $BF8F, $55C0, $4257, $4400, $1E80;
-
- function CompHS (a1, a2: univ longInt): boolean;
- inline
- $BF8F, $54C0, $4257, $4400, $1E80;
-
- function CompHI (a1, a2: univ longInt): boolean;
- inline
- $BF8F, $52C0, $4257, $4400, $1E80;
-
- (* Register Getting - Address *)
-
- function GetRegA0: Ptr;
- inline
- $2E88; (* movea.l a0,(sp) ; fetch a0 into tos *)
- function GetRegA1: Ptr;
- inline
- $2E89;
- function GetRegA2: Ptr;
- inline
- $2E8A;
- function GetRegA3: Ptr;
- inline
- $2E8B;
- function GetRegA4: Ptr;
- inline
- $2E8C;
- function GetRegA5: Ptr;
- inline
- $2E8D;
- {$IFC not undefined THINK_Pascal}
- function GetRegA6: Ptr;
- inline
- $2E8E;
- {$ENDC}
- function GetRegA7: Ptr;
- inline
- $2E8F;
-
- (* Register Setting - Address *)
-
- procedure SetRegA0 (n: univ Ptr);
- inline
- $205F; (* movea.l (sp)+,a0 ; pop n into a0 *)
- procedure SetRegA1 (n: univ Ptr);
- inline
- $225F;
- procedure SetRegA2 (n: univ Ptr);
- inline
- $245F;
- procedure SetRegA3 (n: univ Ptr);
- inline
- $265F;
- procedure SetRegA4 (n: univ Ptr);
- inline
- $285F;
- procedure SetRegA5 (n: univ Ptr);
- inline
- $2A5F;
- procedure SetRegA6 (n: univ Ptr);
- inline
- $2C5F;
- procedure SetRegA7 (n: univ Ptr);
- inline
- $2E5F;
-
- (* Register Getting - Data *)
-
- function GetRegD0: longint;
- inline
- $2E80; (* move.l d0,(sp) ; fetch d0 into tos *)
- function GetRegD1: longint;
- inline
- $2E81;
- function GetRegD2: longint;
- inline
- $2E82;
- function GetRegD3: longint;
- inline
- $2E83;
- function GetRegD4: longint;
- inline
- $2E84;
- function GetRegD5: longint;
- inline
- $2E85;
- function GetRegD6: longint;
- inline
- $2E86;
- function GetRegD7: longint;
- inline
- $2E87;
-
- (* Register Setting - Data *)
-
- procedure SetRegD0 (n: univ longint);
- inline
- $201F; (* move.l (sp)+,(d0) ; pop n into d0 *)
- procedure SetRegD1 (n: univ longint);
- inline
- $221F;
- procedure SetRegD2 (n: univ longint);
- inline
- $241F;
- procedure SetRegD3 (n: univ longint);
- inline
- $261F;
- procedure SetRegD4 (n: univ longint);
- inline
- $281F;
- procedure SetRegD5 (n: univ longint);
- inline
- $2A1F;
- procedure SetRegD6 (n: univ longint);
- inline
- $2C1F;
- procedure SetRegD7 (n: univ longint);
- inline
- $2E1F;
-
- procedure BSETW (var l: integer; num: integer);
- inline
- $301F, $205F, $3210, $01C1, $3081;
-
- procedure BCLRW (var l: integer; num: integer);
- inline
- $301F, $205F, $3210, $0181, $3081;
-
- implementation
-
- {$IFC undefined THINK_Pascal}
- uses
- Memory;
- {$ENDC}
-
- function GetGlobalB (ad: univ longint): SignedByte;
- begin
- GetGlobalB := Ptr(ad)^;
- end; (* GetGlobalB *)
-
- procedure SetGlobalB (ad: univ longint; b: SignedByte); (* not univ cause}
- {I dont trust Pascal *)
- begin
- Ptr(ad)^ := b;
- end; (* GetGlobalB *)
-
- type
- intPtr = ^integer;
-
- function GetGlobalW (ad: univ longint): integer;
- begin
- GetGlobalW := intPtr(ad)^;
- end; (* GetGlobalB *)
-
- procedure SetGlobalW (ad: univ longint; w: univ integer);
- begin
- intPtr(ad)^ := w;
- end; (* GetGlobalB *)
-
- type
- longPtr = ^longint;
-
- function GetGlobalL (ad: univ longint): longint;
- begin
- GetGlobalL := longPtr(ad)^;
- end; (* GetGlobalB *)
-
- procedure SetGlobalL (ad: univ longint; l: univ longint);
- begin
- longPtr(ad)^ := l;
- end; (* GetGlobalB *)
-
- function GetGlobalS (ad: univ longint): Str255;
- var
- tmp: Str255;
- begin
- BlockMove(pointer(ad), @tmp, sizeof(tmp));
- GetGlobalS := tmp;
- end; (* GetGlobalB *)
-
- procedure SetGlobalS (ad: univ longint; s: Str255); (* only bashes}
- {len+1 chars *)
- begin
- BlockMove(@s, pointer(ad), Length(s) + 1);
- end; (* GetGlobalB *)
-
- end. (* LowLevel *)